$('.distributor-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "customer/list?type=1&servantId=" + $("#servantId").val(),
		"data" : function(d) {
            var query = $("#query").serializeObject();
            query["size"] = d.length;
            query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
            var json = jQuery.parseJSON( data );
            json.recordsTotal = json.totalElements;
            json.recordsFiltered = json.totalElements;
            json.data = json.content;
 
            return JSON.stringify( json );
        }
	 },
	 "columns": [
	             { "data": "name" },
	             { "data": "levelName" },
	             { "data": "servantName" },
	             { "data": "recommendDistributorName" },
	             { "data": "phoneNo" },
	             { "data": "allRebate" },
	             { "data": "allWithdrawRebate" },
	             {
	            	 render : function(data, type, row, meta) {
	            		 return row.province + row.city + row.area + row.address;
	            	 }
	             },
	             {
	            	 render : function(data, type, row, meta) {
	            		 if(row.auditStatus == '0'){
	            			 return '待审核';
	            		 }else if(row.auditStatus == '1'){
	            			 return '通过';
	            		 }else if(row.auditStatus == '2'){
	            			 return '拒绝';
	            		 }else{
	            			 return '未知';
	            		 }
	                 }
	             }
     ],
     "drawCallback": function( settings ) {
      }
});


$('.cOrder-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "cOrder/list?servantId=" + $("#servantId").val(),
		"data" : function(d) {
           var query = $("#query").serializeObject();
           query["size"] = d.length;
           query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
           var json = jQuery.parseJSON( data );
           json.recordsTotal = json.totalElements;
           json.recordsFiltered = json.totalElements;
           json.data = json.content;

           return JSON.stringify( json );
       }
	 },
	 "columns": [
	     { "data": "customerName" },
	     { "data": "customerPhoneNo" },
        { "data": "distributorName" },
        { "data": "distributorPhoneNo" },
        { "data": "distributorRebate" },
        { "data": "servantName" },
        { "data": "servantRebate" },
        { "data": "projectName" },
        { "data": "amount" },
        {
       	 render : function(data, type, row, meta) {
       		 if(row.isBalance == '0'){
       			 return '已结算';
       		 }else if(row.isBalance == '1'){
       			 return '未结算';
       		 }else {
       			 return '未知';
       		 }
            }
        }
    ],
    "drawCallback": function( settings ) {
     }
});

$('.withDrawBook-datatable').DataTable({
	 "ajax" : {
		"url" : contextpath + "withdrawBook/list?servantId=" + $("#servantId").val(),
		"data" : function(d) {
           var query = $("#query").serializeObject();
           query["size"] = d.length;
           query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
           var json = jQuery.parseJSON( data );
           json.recordsTotal = json.totalElements;
           json.recordsFiltered = json.totalElements;
           json.data = json.content;

           return JSON.stringify( json );
       }
	 },
	 "columns": [
        { "data": "name" },
        {
       	 render : function(data, type, row, meta) {
       		 if(row.type == '0'){
       			 return '渠道商';
       		 }else if(row.type == '1'){
       			 return '服务老师';
       		 }else {
       			 return '未知';
       		 }
            }
        },
        { "data": "withdrawRebate" },
        {
       	 render : function(data, type, row, meta) {
       		 if(row.status == '0'){
       			 return '已提现';
       		 }else if(row.status == '1'){
       			 return '待提现';
       		 }else {
       			 return '未知';
       		 }
            }
        },
        { "data": "customerName" },
        { "data": "bankName" },
        { "data": "bankCardNum" },
        { "data": "createTime" }
    ],
    "drawCallback": function( settings ) {
     }
});

$(function(){

	$('select').select2({
	    minimumResultsForSearch: Infinity
	});	
	
})
